package cn.iocoder.yudao.module.energy.controller.admin.statistics;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.energy.controller.admin.statistics.vo.EnergyStatisticsReqVO;
import cn.iocoder.yudao.module.energy.controller.admin.statistics.vo.EnergyStatisticsRespVO;
import cn.iocoder.yudao.module.energy.service.statistics.EnergyStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 管理后台 - 能源统计
 */
@Tag(name = "管理后台 - 能源统计")
@RestController
@RequestMapping("/energy/statistics")
@Validated
public class EnergyStatisticsController {

    @Resource
    private EnergyStatisticsService statisticsService;

    @GetMapping("/data")
    @Operation(summary = "获取能源统计数据")
    @PreAuthorize("@ss.hasPermission('energy:statistics:query')")
    public CommonResult<EnergyStatisticsRespVO> getEnergyStatistics(@Valid EnergyStatisticsReqVO reqVO) {
        return success(statisticsService.getEnergyStatistics(reqVO));
    }

    @GetMapping("/trend")
    @Operation(summary = "获取能耗趋势数据")
    @PreAuthorize("@ss.hasPermission('energy:statistics:query')")
    public CommonResult<EnergyStatisticsRespVO.EnergyTrendVO[]> getEnergyTrend(@Valid EnergyStatisticsReqVO reqVO) {
        return success(statisticsService.getEnergyTrend(reqVO));
    }

    @GetMapping("/compare")
    @Operation(summary = "获取能耗环比数据")
    @PreAuthorize("@ss.hasPermission('energy:statistics:query')")
    public CommonResult<EnergyStatisticsRespVO.EnergyCompareVO[]> getEnergyCompare(@Valid EnergyStatisticsReqVO reqVO) {
        return success(statisticsService.getEnergyCompare(reqVO));
    }

    @GetMapping("/distribution")
    @Operation(summary = "获取能耗分布数据")
    @PreAuthorize("@ss.hasPermission('energy:statistics:query')")
    public CommonResult<EnergyStatisticsRespVO.EnergyDistributionVO[]> getEnergyDistribution(@Valid EnergyStatisticsReqVO reqVO) {
        return success(statisticsService.getEnergyDistribution(reqVO));
    }
} 